<?php

namespace common\models;

use Yii;

/**
 * This is the model class for table "campus".
 *
 * @property int $ID ID
 * @property int $XXID 学校ID
 * @property string $XQMC 校区名称
 * @property string $XQYWMC 校区英文名称
 * @property string $FZRXM 负责人姓名
 * @property string|null $FZRGH 负责人工号
 * @property string $DZ 地址
 * @property string $YZBM 邮政编码
 * @property string $DHHM 电话号码
 * @property string $DZYX 电子邮箱
 * @property string $JJ 简介
 * @property string $CJSJ 创建时间
 * @property string $ZT 状态
 *
 * @property School $xX
 */
class Campus extends \yii\db\ActiveRecord
{
    /**
     * {@inheritdoc}
     */
    public static function tableName()
    {
        return 'campus';
    }

    /**
     * {@inheritdoc}
     */
    public function rules()
    {
        return [
            [['XXID', 'XQMC', 'XQYWMC', 'FZRXM', 'DZ', 'YZBM', 'DHHM', 'DZYX', 'JJ', 'CJSJ', 'ZT'], 'required'],
            [['XXID'], 'integer'],
            [['JJ'], 'string'],
            [['CJSJ'], 'safe'],
            [['XQMC', 'XQYWMC'], 'string', 'max' => 100],
            [['FZRXM', 'DZYX'], 'string', 'max' => 50],
            [['FZRGH', 'DHHM'], 'string', 'max' => 20],
            [['DZ'], 'string', 'max' => 200],
            [['YZBM'], 'string', 'max' => 6],
            [['ZT'], 'string', 'max' => 10],
            [['XXID'], 'exist', 'skipOnError' => true, 'targetClass' => School::className(), 'targetAttribute' => ['XXID' => 'ID']],
        ];
    }

    /**
     * {@inheritdoc}
     */
    public function attributeLabels()
    {
        return [
            'ID' => 'ID',
            'XXID' => '学校ID',
            'XQMC' => '校区名称',
            'XQYWMC' => '校区英文名称',
            'FZRXM' => '负责人姓名',
            'FZRGH' => '负责人工号',
            'DZ' => '地址',
            'YZBM' => '邮政编码',
            'DHHM' => '电话号码',
            'DZYX' => '电子邮箱',
            'JJ' => '简介',
            'CJSJ' => '创建时间',
            'ZT' => '状态',
        ];
    }

    /**
     * Gets query for [[XX]].
     *
     * @return \yii\db\ActiveQuery
     */
    public function getXX()
    {
        return $this->hasOne(School::className(), ['ID' => 'XXID'])->inverseOf('campuses');
    }
}
